package org.lonetree.tc.webapp.actions;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.lonetree.tc.core.Book;
import org.lonetree.tc.core.User;
import org.lonetree.tc.core.Book.Isbn;
import org.lonetree.tc.core.User.EmailAddress;
import org.lonetree.tc.core.User.Username;
import org.lonetree.tc.core.dao.BookDAO;
import org.lonetree.tc.core.dao.DAOFactory;
import org.lonetree.tc.core.dao.UserDAO;
import org.lonetree.tc.webapp.forms.UserForm;

public class PrepForMyBooks extends SecureAction {

	@Override
	protected ActionForward executeSecure(ActionMapping mapping,
			ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		// TODO Auto-generated method stub
		
			try{
				request.setAttribute("books", getCurrentUser().getMyBooks());
				request.setAttribute("courses", getCurrentUser().getMySections());
				String manage = request.getParameter("manage");
				if("books".equals(manage))					
					return mapping.findForward("success_manage_books");
				else if("sections".equals(manage))
					return mapping.findForward("success_manage_sections");
				else
					return mapping.findForward("success");
			}
			catch (Exception e)
			{
				return mapping.findForward("failure");
			}
				
		}

	}
